package com.copc.common.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;


public class OrderNoGenerator {
	private static final String DATE_FORMAT = "yyyyMMddHHmmss";
	private static final int RANDOM_MAX = 99999; // 五位随机数的最大值

	private static SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
	private static Random random = new Random();

	public static String generateOrderNumber() {
		String timestamp = dateFormat.format(new Date());
		int randomValue = random.nextInt(RANDOM_MAX + 1); // 生成0到RANDOM_MAX之间的随机数

		// 拼接时间戳和随机数，补足15位
		String orderNumber = timestamp + String.format("%05d", randomValue);

		return orderNumber;
	}
}
